package com.mopon.test.tx.service.impl;

import com.mopon.test.tx.dao.AccountDao;
import com.mopon.test.tx.dao.impl.AccountDaoImpl;
import com.mopon.test.tx.domain.Account;
import com.mopon.test.tx.service.BusinessService;

//业务层控制事务
public class BusinessServiceImpl implements BusinessService {
    private AccountDao dao = new AccountDaoImpl();
    public void transfer(String sourceAccountName, String targetAccontName,
            float money) {
        Account sAccount = dao.findByName(sourceAccountName);
        Account tAccount = dao.findByName(targetAccontName);
        sAccount.setMoney(sAccount.getMoney() - money);
        tAccount.setMoney(tAccount.getMoney() + money);
        dao.updateAcount(sAccount);
        int i=1/0;
        dao.updateAcount(tAccount);

    }

}
